<template>
  <div class="player-info">
    <div v-for="(player, index) in players" :key="index" 
         class="player-card" 
         :class="[`player-${player.id}`, { 'active-player': isCurrentPlayer(player) }]">
      <div class="player-avatar">
        <img :src="player.avatar" alt="玩家头像" />
      </div>
      <div class="player-details">
        <div class="player-name">{{ player.name }}</div>
        <div class="player-money">
          <span class="money-icon">💵</span>
          {{ player.money }}
        </div>
      </div>
      <div v-if="isCurrentPlayer(player)" class="current-player-indicator">
        <span>当前回合</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PlayerInfo',
  props: {
    players: {
      type: Array,
      required: true
    },
    currentPlayerIndex: {
      type: Number,
      required: true
    }
  },
  methods: {
    isCurrentPlayer(player) {
      return this.players.indexOf(player) === this.currentPlayerIndex;
    }
  }
};
</script>

<style scoped>
.player-info {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
  background-color: #424242;
  padding: 15px;
  border-radius: 10px;
}

.player-card {
  display: flex;
  align-items: center;
  color: white;
  padding: 10px;
  border-radius: 8px;
  position: relative;
  transition: transform 0.3s;
  width: 30%;
}

.player-card:hover {
  transform: translateY(-5px);
}

.player-1 { background-color: #e53935; }
.player-2 { background-color: #1e88e5; }
.player-3 { background-color: #43a047; }

.active-player {
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
  transform: scale(1.05);
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  margin-right: 10px;
  background-color: #fff;
  border: 2px solid white;
}

.player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-details {
  flex-grow: 1;
}

.player-name {
  font-weight: bold;
  margin-bottom: 5px;
}

.player-money {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
}

.current-player-indicator {
  position: absolute;
  top: -10px;
  right: 10px;
  background-color: #ffc107;
  color: #333;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: bold;
}
</style>